package com.ruoyi.shop.service.impl;

import java.util.List;

import com.ruoyi.shop.api.RemotePetrolService;
import com.ruoyi.shop.api.domain.ChePetrol;
import com.ruoyi.shop.api.domain.PetrolImage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.mapper.PetrolImageMapper;
import com.ruoyi.shop.service.IPetrolImageService;

/**
 * 加油站照片Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-04
 */
@Service
public class PetrolImageServiceImpl implements IPetrolImageService 
{
    @Autowired
    private PetrolImageMapper petrolImageMapper;

    @Autowired
    private RemotePetrolService remotePetrolService;

    /**
     * 查询加油站照片
     * 
     * @param id 加油站照片主键
     * @return 加油站照片
     */
    @Override
    public PetrolImage selectPetrolImageById(Long id)
    {
        return petrolImageMapper.selectPetrolImageById(id);
    }

    /**
     * 查询加油站照片列表
     * 
     * @param petrolImage 加油站照片
     * @return 加油站照片
     */
    @Override
    public List<PetrolImage> selectPetrolImageList(PetrolImage petrolImage)
    {
        List<PetrolImage> petrolImages = petrolImageMapper.selectPetrolImageList(petrolImage);
        for (PetrolImage image : petrolImages) {
            ChePetrol info1 = remotePetrolService.getInfo1(image.getPetrolId(), null);
            image.setPetrol(info1);
        }
        return petrolImages;
    }

    /**
     * 新增加油站照片
     * 
     * @param petrolImage 加油站照片
     * @return 结果
     */
    @Override
    public int insertPetrolImage(PetrolImage petrolImage)
    {
        return petrolImageMapper.insertPetrolImage(petrolImage);
    }

    /**
     * 修改加油站照片
     * 
     * @param petrolImage 加油站照片
     * @return 结果
     */
    @Override
    public int updatePetrolImage(PetrolImage petrolImage)
    {
        return petrolImageMapper.updatePetrolImage(petrolImage);
    }

    /**
     * 批量删除加油站照片
     * 
     * @param ids 需要删除的加油站照片主键
     * @return 结果
     */
    @Override
    public int deletePetrolImageByIds(Long[] ids)
    {
        return petrolImageMapper.deletePetrolImageByIds(ids);
    }

    /**
     * 删除加油站照片信息
     * 
     * @param id 加油站照片主键
     * @return 结果
     */
    @Override
    public int deletePetrolImageById(Long id)
    {
        return petrolImageMapper.deletePetrolImageById(id);
    }

    @Override
    public PetrolImage selectPetrolImageByPetrolId(Long petrolId) {
        return petrolImageMapper.selectPetrolImageByPetrolId(petrolId);
    }
}
